@*
    For more information on enabling MVC for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860
*@
@{
    string id = ViewData["id"].ToString();
}
<script type="text/javascript">
    window.onload = function () {
        jump();
    }
    function deldata(id) {
        $.ajax({
            type: "post",
            url: "/Account/Deldata",
            data: { "id": id },
            success: function (data) {
                alert(data);
            },
            error: function (err) { alert(err); }
        });
    }
    function jump2() {
        var classname = document.getElementById("classname").value;
        $.ajax({
            type: "post",
            url: "/Account/InfoListByType",
            data: { "id": @id, "classname":classname},
            success: function (data) {
                showData(data);
            },
            error: function (err) {
                alert(err);
            }
        });
    }
    function showData(data) {
        var max = 0;
        var obj = JSON.parse(data);
        var html = "";
        for (var i = 0; i < obj.length; i++) {
            html += "<tr>";
            html += "<td>" + obj[i].changeTime + "</td>";
            var type = obj[i].type == "0" ? "支出" : "收入";
            html += "<td>" + type + "</td>";
            html += "<td>" + obj[i].value + "</td>";
            html += "<td>" + obj[i].remarks + "</td>";
            html += "<td><span onclick='deldata('" + obj[i].id+"')'> 删除</span</td>";
            html += "</tr>";
            max += Number(obj[i].value);
        }
        document.getElementById("bbddyy").innerHTML = html;
        document.getElementById("all").innerHTML = max;
    }
</script>

<div>
    <input type="text" value="non" id="classname" /><input type="button" value="查" onclick="jump2()" />
    <p id="all"></p>
</div>
<div>
    <table class="table">
        <thead>
            <tr>
                <th>时间</th>
                <th>类型</th>
                <th>值</th>
                <th>备注</th>
                <th>删除</th>
            </tr>
        </thead>
        <tbody id="bbddyy">
        </tbody>
    </table>
</div>